<!DOCTYPE html>
<html>
<head>
    <title>CPU 监控</title>
    <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</head>
<body>
    <div class="container">
        {% if data.code == 0 %}
            <h1>{{ data.msg }}</h1>
            <table>
                <thead>
                    <tr>
                        <th>核心</th>
                        <th>使用率</th>
                        <th>状态</th>
                        <th>时间</th>
                    </tr>
                </thead>
                <tbody>
                    {% for item in data.data %}
                    <tr>
                        <td>{{ item.cpu_core }}</td>
                        <td>
                            <div class="progress-bar"
                                 style="width: {{ item.cpu_used }}%">
                                {{ "%.2f"|format(item.cpu_used) }}%
                            </div>
                        </td>
                        <td class="status-{{ 'safe' if item.cpu_used < 10 else 'warning' if item.cpu_used < 30 else 'danger' }}">
                            {{ '正常' if item.cpu_used < 10 else '注意' if item.cpu_used < 30 else '警告' }}
                        </td>
                        <td>{{ item.date }}</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        {% else %}
            <div class="error">
                <h2>错误: {{ data.code }}</h2>
                <p>{{ data.msg }}</p>
            </div>
        {% endif %}
    </div>
</body>
</html>